<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Raul
 * Date: 5/29/13
 * Time: 4:13 PM
 * To change this template use File | Settings | File Templates.
 */
define('BASEPATH', true);
define('ENV', 'master');
define('TIME', 3600);
define('STATUS', 0);
date_default_timezone_set('Asia/Shanghai');
$projectPath = dirname(dirname(__FILE__));
require_once($projectPath . '/application/config/database.php');

$db = new mysqli($db[ENV]['hostname'], $db[ENV]['username'], $db[ENV]['password'], $db[ENV]['database']);

delIPs();
$db->close();

function delIPs() {
    global $db;
    $sql = "DELETE FROM mobility_ip WHERE status = ".STATUS." AND ctime < ".(time() - TIME * 24);
    $query = $db->query($sql);

    $sql = "DELETE FROM mobility_ip_error WHERE ctime < ".(time() - TIME * 24);
    $query = $db->query($sql);
}